﻿namespace iTool.PluginCore.Connector
{
    public interface IUrlPathToUrlTemplateMatcher
    {
        bool Match(string request, string queryString, RouteTemplate template);
    }
    public class RegExUrlMatcher : IUrlPathToUrlTemplateMatcher
    {
        public bool Match(string request, string queryString, RouteTemplate template)
        {
            if (!template.ContainsQueryString)
            {
                return template.Pattern.IsMatch(request);
            }

            return template.Pattern.IsMatch($"{request}{queryString}");
        }
    }
}
